<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h2>Editar Pergunta</h2>
            <h:form id="form" acceptcharset="utf-8">
                <p:growl id="msg" life="5000"/>
                <p:panel styleClass="container_24 clearfix " style="background: none; border: none;">
                    <p class="subtitle">Dados</p>

                    <p:outputLabel value="Título: " styleClass="grid_3" />
                    <p:inputText styleClass="grid_18" value="#{managerEditIssues.editIssues.title}" />
                    <p:outputLabel value="Orientação:" styleClass="grid_3"/>
                    <p:inputTextarea cols="95" value="#{managerEditIssues.editIssues.orientacion}" styleClass="grid_18"/>
                    <div class="clear"/>
                    <p class="subtitle">#{empty managerEditIssues.editIssues.options ? '':'Alternativas'}</p>
                    <p:commandButton title="Nova alternativa"
                                     icon="ui-icon-circle-plus"
                                     value="Adicionar Alternativas" style="float:right; margin-top: -50px;"
                                     rendered="#{managerEditIssues.editIssues.typeIssues ne 'OPEN'}" onclick="dlg.show()" />

                    <div class="clear"/>
                    <ul class="alternatives" style="padding-left: 60px;list-style-type:lower-alpha; ">
                        <ui:repeat value="#{managerEditIssues.editIssues.options}" var="o">
                            <li style="float: left;width: 100%">  
                                <p:selectOneRadio rendered="#{managerEditIssues.editIssues.typeIssues eq 'CHOOSEONE'}"  style="float: left;display: block" id="options" >    <f:selectItem itemLabel="" itemValue="1" />   </p:selectOneRadio>
                                <p:selectBooleanCheckbox  rendered="#{managerEditIssues.editIssues.typeIssues eq 'CHOICEMULTIPLE'}" />  


                                <span style="padding-top: 6px;float: left;width: 90%">
                                    <p:inplace id="ajaxInplace" editor="true" style="margin: 0px 10px;width: 300px ;float: left;padding: 0px !important">  
                                        <p:inputText value="#{o.title}" required="true" label="text" style="float : left" /> 
                                        <br/><br/>
                                        <p:rating style="margin-right: 17px;float: left" value="#{o.score}" cancel="true" stars="5"/> 
                                    </p:inplace>                                  
                                </span>   
                                <p:commandButton title="Excluir Alternativa" icon="ui-icon-close" actionListener="#{managerEditIssues.removeOption(o)}" update="@form" />


                            </li>
                            <br/>
                        </ui:repeat>


                    </ul>     
                    <br/>
                    <div class="buttonAction">
                        <p:commandButton value="Salvar" process="@form" icon="ui-icon-disk" styleClass="ui-priority-primary"
                                         actionListener="#{managerEditIssues.update()}" update="@form" />
                        <p:commandButton value="Voltar" icon="ui-icon-arrowreturnthick-1-w" 
                                         actionListener="#{managerRedirect.redirect('editIssues.xhtml')}" immediate="true"/>
                    </div>

                    <p:dialog header="Cadastrar Alternativa" widgetVar="dlg" modal="true" width="400">  
                        <h:panelGrid columns="2">
                            <h:outputText value="Nome :" />
                            <h:inputText value="#{managerEditIssues.options.title}" size="32" />
                            <h:outputLabel value="Pontos :" />
                            <p:rating value="#{managerEditIssues.options.score}" cancel="true" stars="5"/> 
                        </h:panelGrid>
                        <center>
                            <p:commandButton  icon="ui-icon-circle-plus"
                                              value="Adicionar Alternativas" 
                                              actionListener="#{managerEditIssues.addOption()}" 
                                              oncomplete="dlg.hide()" update="@form"/>

                        </center>
                    </p:dialog>  

                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>
</html>





